home *** CD-ROM | disk | FTP | other *** search
- property button, bar, direction, min, max, percentage, range, offset, location, name, downmem, msgMovie, msgSprite, msgSpriteNum, sliderMsg, defaultVal
- global gpartslist, grgbspnum, grgblist, gmyphotonum
-
- on getPropertyDescriptionList
- set s to the currentSpriteNum
- if s > 0 then
- set nameDef to the name of member the member of sprite s
- set memDef to nameDef & "*"
- set barDef to s - 1
- end if
- set plist to [:]
- addProp(plist, #name, [#comment: "Slider Name:", #format: #string, #default: nameDef])
- addProp(plist, #bar, [#comment: "Range channel:", #format: #integer, #default: barDef])
- addProp(plist, #direction, [#comment: "Direction:", #format: #symbol, #default: #horizontal, #range: [#horizontal, #vertical]])
- addProp(plist, #defaultVal, [#comment: "Default Value (%):", #format: #integer, #default: 1])
- addProp(plist, #msgMovie, [#comment: "Message Movie:", #format: #boolean, #default: 1])
- addProp(plist, #msgSprite, [#comment: "Message Sprite:", #format: #boolean, #default: 0])
- addProp(plist, #msgSpriteNum, [#comment: "Sprite Number:", #format: #integer, #default: 1])
- addProp(plist, #sliderMsg, [#comment: "Send this message:", #format: #string, #default: "sliderIsMoving"])
- return plist
- end
-
- on getBehaviorDescription
- return "Creates a slider"
- end
-
- on beginSprite me
- set sliderMsg to value("#" & sliderMsg)
- set button to the spriteNum of me
- setDirection(me)
- set offset to 0
- if defaultVal < 1 then
- set defaultVal to 1
- end if
- if defaultVal > 100 then
- set defaultVal to 100
- end if
- if voidp(grgblist) then
- set grgblist to [#redShift: 255, #greenShift: 255, #blueShift: 255]
- sort(grgblist)
- end if
- case name of
- "Red":
- set v to getaProp(grgblist, #redShift)
- "Grn":
- set v to getaProp(grgblist, #greenShift)
- "Blu":
- set v to getaProp(grgblist, #blueShift)
- end case
- set val to 100 * (v + 255) / 510
- set the text of field member (name & "Value") to string(val)
- setSlider(me, val)
- return me
- end
-
- on setBar me, b
- set bar to b
- setDirection(me)
- end
-
- on setLocation me, l
- case direction of
- #horizontal:
- set the locV of sprite button to l
- #vertical:
- set the locH of sprite button to l
- end case
- setSlider(me, percentage)
- end
-
- on mouseDown me
- operate(me)
- end
-
- on operate me
- repeat while the mouseDown
- if direction = #horizontal then
- set mh to the mouseH
- if mh < min then
- set mh to min
- end if
- if mh > max then
- set mh to max
- end if
- set the locH of sprite button to mh
- set offset to mh - min
- else
- set mv to the mouseV
- if mv > min then
- set mv to min
- end if
- if mv < max then
- set mv to max
- end if
- set the locV of sprite button to mv
- set offset to min - mv
- end if
- set percentage to offset * 100 / range
- set the text of field (name & "Value") to string(percentage)
- tell getAt(the windowList, 1)
- if value(grgbspnum) <> 0 then
- set xxx to value("#" & string(grgbspnum))
- setalpha(getProp(gpartslist, xxx), name, percentage)
- end if
- end tell
- updateStage()
- end repeat
- end
-
- on setSlider me, P, Flag
- set percentage to P
- set offset to range * percentage / 100
- case direction of
- #horizontal:
- set the locH of sprite button to offset + min
- #vertical:
- set the locV of sprite button to min - offset
- end case
- if voidp(Flag) then
- tell getAt(the windowList, 1)
- if value(grgbspnum) <> 0 then
- set xxx to value("#" & string(grgbspnum))
- setalpha(getProp(gpartslist, xxx), name, percentage)
- end if
- end tell
- end if
- updateStage()
- end
-
- on setDirection me, d
- if not voidp(d) then
- set direction to d
- end if
- case direction of
- #horizontal:
- set min to the left of sprite bar
- set max to the right of sprite bar
- set range to max - min
- #vertical:
- set min to the bottom of sprite bar
- set max to the top of sprite bar
- set range to min - max
- end case
- end
-
- on reflectrealvalue me
- case gmyphotonum of
- 2, 28:
- exit
- otherwise:
- if voidp(grgblist) then
- set grgblist to [#redShift: 255, #greenShift: 255, #blueShift: 255]
- sort(grgblist)
- end if
- tell getAt(the windowList, 1)
- set rgbmem to the member of sprite grgbspnum
- set nowrgb to geteffectargs(rgbmem, #rgb)
- end tell
- case name of
- "Red":
- set v to getaProp(nowrgb, #redShift)
- "Grn":
- set v to getaProp(nowrgb, #greenShift)
- "Blu":
- set v to getaProp(nowrgb, #blueShift)
- end case
- set val to 100 * (v + 255) / 510
- set the text of field member (name & "Value") to string(val)
- setSlider(me, val)
- end case
- end
-